home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / func / box.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  2.2 KB  |  104 lines

  1. /*
  2.  * box.c -- routines for selecting box regions
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <X11/Xlib.h>
  8.  
  9. #include "ui.h"
  10. #include "reg.h"
  11. #include "common.h"
  12. #include "llist.h"
  13. #include "display.h"
  14. #include "scale.h"
  15.  
  16. draw_box(reg)
  17.     struct region *reg;
  18. {
  19.     box_interp(reg->r_dlist, reg->r_plist);
  20.     draw_dlist(img_win->d_xid, reg->r_dlist);
  21. }
  22.  
  23. box_interp(dlist, ptlist)
  24.     struct dlist *dlist;
  25.     struct plist *ptlist;
  26. {
  27.     struct plist *org, *dst;
  28.     XPoint    p1, p2;
  29.     struct dlist *seg;
  30.  
  31.     seg = dlist;
  32.     org = ptlist;
  33.     dst = org->next;
  34.     p1 = org->pt;
  35.     p2.y = p1.y;
  36.     p2.x = dst->pt.x;
  37.     ras_line(p1, p2, seg, orig_ximg, orig_img);
  38.  
  39.     seg = (struct dlist *) malloc(sizeof(struct dlist));
  40.     seg->next = seg->prev = NULL;
  41.     seg->len = seg->flags = 0;
  42.     llist_add((llist *) seg, (llist **) & dlist, (llist **) NULL);
  43.  
  44.  
  45.     p1 = p2;
  46.     p2 = dst->pt;
  47.     ras_line(p1, p2, seg, orig_ximg, orig_img);
  48.  
  49.     seg = (struct dlist *) malloc(sizeof(struct dlist));
  50.     seg->next = seg->prev = NULL;
  51.     seg->len = seg->flags = 0;
  52.     llist_add((llist *) seg, (llist **) & dlist, (llist **) NULL);
  53.  
  54.     p1 = p2;
  55.     p2.x = org->pt.x;
  56.     ras_line(p1, p2, seg, orig_ximg, orig_img);
  57.  
  58.     seg = (struct dlist *) malloc(sizeof(struct dlist));
  59.     seg->next = seg->prev = NULL;
  60.     seg->len = seg->flags = 0;
  61.     llist_add((llist *) seg, (llist **) & dlist, (llist **) NULL);
  62.  
  63.     p1 = p2;
  64.     p2 = org->pt;
  65.     ras_line(p1, p2, seg, orig_ximg, orig_img);
  66. }
  67.  
  68. box_direction(pl)
  69.     struct plist *pl;
  70. {
  71.     int       h, v;
  72.  
  73.     v = pl->next->pt.y - pl->pt.y;
  74.     h = pl->next->pt.x - pl->pt.x;
  75.     if (h > v)
  76.     return HORIZONTAL;
  77.     else
  78.     return VERTICAL;
  79. }
  80.  
  81.  
  82. /*****************************************************************/
  83.  
  84. char     *
  85. box_info(reg)            /* create string containing message giving
  86.                  * info on spline */
  87.     struct region *reg;
  88. {
  89.     char      mesg[80];
  90.     int       x1, x2, y1, y2, width, height;
  91.  
  92.     x1 = reg->r_plist->pt.x;
  93.     y1 = reg->r_plist->pt.y;
  94.     x2 = reg->r_plist->next->pt.x;
  95.     y2 = reg->r_plist->next->pt.y;
  96.     width = abs(x2 - x1);
  97.     height = abs(y2 - y1);
  98.  
  99.     sprintf(mesg, "Box cols: %d pxls;  rows: %d pxls;  area: %d ",
  100.         width, height, width * height);
  101.  
  102.     return (mesg);
  103. }
  104.